package com.quectel.core.module.device.entity.mongo;

import com.quectel.constant.BackupConfigConstants;
import com.quectel.core.constants.MongoCollectionConstants;
import com.quectel.core.module.device.entity.DeviceCommandTemplateEntity;
import com.quectel.core.module.device.entity.DeviceEntity;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;
import java.util.Map;

/**
 * 说明:
 *
 * @author: rananxin
 * @email: ryan.ran@quectel.com
 * @date: 2021/11/4 3:04 下午
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@CompoundIndex(name = "idx_device_id", def = "{'deviceEntity._id': 1}", background = true)
@CompoundIndex(name = "idx_tenant_village", def = "{'deviceEntity.tenantId': 1,'deviceEntity.villageId': 1}", background = true)
@Document(MongoCollectionConstants.DEVICE_COMMAND_LOG)
public class MongoDeviceCommandLogModel implements MongoBaseModel {

    @MongoId
    private Long id;

    private Map<String, Object> sendOriginalMsg;

    private String sendParsedMsg;

    @Indexed(name = "idx_send_time", background = true, expireAfterSeconds = BackupConfigConstants.MONGO_LOG_DATA_DEFAULT_RETAIN_SECONDS)
    private Date sendTime;

    private Byte sendStatus;

    private String receiveOriginalMsg;

    private Map<String, Object> receiveParsedMsg;

    private Date receiveTime;

    private Byte receiveStatus;

    /**
     * 操作员类型 1是管理员 2是业主
     */
    private Byte operatorType;

    private Long operatorId;


    private DeviceEntity deviceEntity;

    private DeviceCommandTemplateEntity deviceCommandTemplateEntity;


}
